<extend name="Layout:layout_list" />
<block name="body_content_block">
    <table id="main_grid" class="easyui-datagrid" data-url="{:AddonU('Extension/get_extension_list_json')}"></table>
    <div id="tb" style="padding:2px 5px;">
        <div style="margin-bottom: 5px; border-bottom:solid 1px #dddddd;">
            <if condition="equal_permission_name('新增分机',$loginData['role_id'])">
                <a href="{:AddonU('Extension/extension_edit')}" class="easyui-linkbutton lnk_grid_add" iconCls="icon-add" plain="true">新增</a>
                <a href="{:AddonU('Extension/extension_edit','batch=1')}" class="easyui-linkbutton lnk_grid_add" iconCls="icon-add" plain="true">批量添加</a>
            </if>
            <if condition="equal_permission_name('编辑分机',$loginData['role_id'])">
                <a href="{:AddonU('Extension/extension_edit','id=varkey')}" class="easyui-linkbutton lnk_grid_edit" iconCls="icon-edit" plain="true">编辑</a>
            </if>
            <if condition="$loginData['USER_KEY'] eq 'TTF'">
                <a href="{:AddonU('Extension/extension_batch_edit','id=varkey')}" class="easyui-linkbutton lnk_grid_edit" iconCls="icon-card" plain="true" data-window-mode="single">快速编辑</a>
            </if>
            <if condition="equal_permission_name('删除分机',$loginData['role_id'])">
                <a href="{:AddonU('Extension/extension_delete','id=varkey')}" class="easyui-linkbutton lnk_grid_remove" iconCls="icon-remove" plain="true" data-success-fn="show_reload_tip">删除</a>                
            </if>
            <a href="#" class="easyui-linkbutton lnk_grid_search" iconCls="icon-search" plain="true">搜索</a>
            <a href="{:AddonU('Extension/forwarding_edit','id=varkey')}" class="easyui-linkbutton lnk_grid_edit" iconCls="icon-transfer" plain="true">呼叫转移</a>
        </div>
    </div>
    <!--隐藏区域-->
    <div style="display:none">
        <!--表格查询对话框-->
        <div id="dlg_search" style="padding:10px">
            <form method="get" action="{:AddonU('Extension/get_extension_list_json')}" data-export-url="{:AddonU('Extension/extension_export')}">
                分机号：<input type="text" name="userName" class="easyui-textbox" />
                中继名称：<input type="text" name="ctiTrunk" id="ctiTrunk" class="easyui-combobox" data-url="{:AddonU('Trunk/get_json')}" />
                <if condition="$isSuperAdmin">
                    租户：<input type="text" name="siteID" id="siteID" class="easyui-combobox" data-url="{:AddonU('Admin/get_admin_json')}" />
                    <else/>
                    <input type="hidden" name="siteID" value="{$loginData.siteID}"/>
                </if>
            </form>
        </div>
        <!--/表格查询对话框-->
    </div>
    <!--/隐藏区域-->
</block>
<block name="body_after_block">
    <script type="text/javascript">
        // 页面初始化
        var curd_grid = CurdGrid.newInstance();
        curd_grid.before_search_dialog = function () {
            $('#siteID').combobox({url: $('#siteID').data('url'), valueField: 'id', textField: 'text'});
            $('#ctiTrunk').combobox({url: $('#ctiTrunk').data('url'), valueField: 'id', textField: 'text'});
        }
        curd_grid.config({
            title: '分机管理',
            toolbar: '#tb',
            fitColumns: true,
            showFooter: true,
            columns: [[
                    {field: 'ck', checkbox: true},
                    {title: "租户ID", field: "siteIDText", sortable: true},
                    {title: "分机号", field: "userName", sortable: true},
                    {title: "分机密码", field: "extensionPassword", sortable: true},
                    {title: "中继名称", field: "ctiTrunk", sortable: true},
                    {title: "主叫号码", field: "ctiCallerNo", sortable: true},
                    {title: "注册端口", field: "sipPort", sortable: true},
                    {title: "录音标识", field: "recStateText", sortable: true},
                    {title: "中继注册模式", field: "ctiRegModeText", sortable: true},
                    {title: "激活状态", field: "activatedText", sortable: true},
                    {title: "呼叫转移", field: "forwardingStateText", sortable: true},
                    {title: "创建时间", field: "createdTime", sortable: true},
                    {title: "编号", field: "id", hidden: true},
                ]],
        });
        curd_grid.init();
    </script>
</block>